<%@page import="java.util.Date"%>
<%@page import="org.apache.naming.java.javaURLContextFactory"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="com.hellowordweb.scmysql.SCMysqlSchool"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<jsp:useBean id="uslogin" class="com.hellowordweb.usermange.LoginVerify" scope="request"/>
	<jsp:setProperty property="*" name="uslogin"/>
	<%
		String name=uslogin.getUsername();
		String password=uslogin.getPassword();
		Cookie cookie = new Cookie("mrCookie", name+"#"+new Date().toLocaleString());
		
		cookie.setMaxAge(60*60);//(60*60*24*30); //设置cookie有效期限为30天
		response.addCookie(cookie);
		
		boolean frepeat = false;
		Connection connection = SCMysqlSchool.connect();
		ResultSet rs = SCMysqlSchool.getSelectStudentResultSet(connection);
		while (rs.next())
		{
			if (name.equals(rs.getString("username")) && password.equals(rs.getString("password")))
			{
				frepeat = true;
				break;
			}
		}
		if (frepeat)
		{
			//<jsp:forward page="/false.jsp"/>
			//<jsp:forward page="/success.jsp"/>
	%>
		成功！<a href="index.jsp">[ 返回 ]</a>
	<%
		}
		else
		{
	%>
		失败！<a href="index.jsp">[ 返回 ]</a>
	<%
		}
	%>
</body>
</html>